package com.luom.springbootinit.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.luom.springbootinit.model.entity.Book;
import com.luom.springbootinit.model.vo.BookAnalysisVO;
import com.luom.springbootinit.model.vo.BookVO;
import com.luom.springbootinit.model.vo.CountAnalysisVO;
import org.apache.ibatis.annotations.Select;

import java.util.List;


/**
* @author 28713
* @description 针对表【book(图书)】的数据库操作Mapper
* @createDate 2024-09-07 21:28:08
* @Entity generator.domain.Book
*/
public interface BookMapper extends BaseMapper<Book> {

    @Select("select sum(inventory) from book where categoryId = #{category}")
    Integer getBookCount(Integer categoryId);

    @Select("SELECT COUNT(*) AS count FROM  borrow_record INNER JOIN book ON book.id = borrow_record.bookId where bookId= #{bookId}")
    Integer getBorrowCount(Integer bookId);

    List<BookAnalysisVO> getTop5Book();

    CountAnalysisVO getCountAnalysis();
}




